﻿#pragma once
// Copyright (c) lanyeo 2020-2021
// Licenced under MIT license. See https://opensource.org/licenses/MIT for details.
// code style
// 1. use forward declaration (尽可能使用前置声明)
// 2. include file sequence [other project>c>c++>third>self project]
// 

#include <core/manager.h>

struct NetworkConf;

class IRawPackHandlerManager : public IManager
{
public:
    virtual void ProcMessage(netlink_t link, const std::string& msg) = 0;
};

class INetworkManager : public IManager
{
public:
    /***
     * 注册处理消息的模块
     * type: 对应枚举RpcMessageType
     */
    virtual bool RegisterRawPackHandle(int type, IRawPackHandlerManager* manager) = 0;
    virtual void ProcMessage(int type, netlink_t link, const std::string& msg) = 0;
    virtual netlink_t AddConnect(const std::string& ip, uint16_t port, uint32_t timeout = UINT32_MAX) = 0;
    virtual int SendOneMessage(netlink_t link, const std::string& msg) = 0;
    virtual const NetworkConf* cfg() = 0;
    virtual void Run() = 0;
};